<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('首页')" />
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>平台通知</h5>
                    <div class="ibox-tools" shiro:hasPermission="system:notice:list">
                        <a href="javascript:;" onclick="openNotices();"><i class="fa fa-chevron-right"></i></a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="table-striped">
                        <table id="notice-table-1" data-mobile-responsive="true"></table>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-6">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>平台公告</h5>
                    <div class="ibox-tools" shiro:hasPermission="system:notice:list">
                        <a href="javascript:;" onclick="openNotices();"><i class="fa fa-chevron-right"></i></a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="table-striped">
                        <table id="notice-table-2" data-mobile-responsive="true"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "system/notice";
    function queryParams1(params) {
        var search = $.table.queryParams(params);
        search.noticeType = '1';
        search.status = '0';
        return search;
    }

    $(function () {
        var options = {
            id: "notice-table-1",
            url: prefix + "/list",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            sortName: "createTime",
            sortOrder: "desc",
            onClickRow: onClickRow,
            queryParams: queryParams1,
            columns: [
                {
                    field: '',
                    title: '序号',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    field: 'noticeTitle',
                    title: '公告标题'
                },
                {
                    field: 'createTime',
                    title: '发布时间'
                }]
        };
        $.table.init(options);
    });

    function queryParams2(params) {
        var search = $.table.queryParams(params);
        search.noticeType = '2';
        search.status = '0';
        return search;
    }

    $(function () {
        var options = {
            id: "notice-table-2",
            url: prefix + "/list",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            sortName: "createTime",
            sortOrder: "desc",
            onClickRow: onClickRow,
            queryParams: queryParams2,
            columns: [
                {
                    field: '',
                    title: '序号',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    field: 'noticeTitle',
                    title: '公告标题'
                },
                {
                    field: 'createTime',
                    title: '发布时间'
                }]
        };
        $.table.init(options);
    });

    function onClickRow(row, $element) {
        var btn = ['确定', '关闭'];
        var options = {
            title: row.noticeTitle,
            width: "1200",
            height: "500",
            url: ctx + "system/notice/view/" + row.noticeId,
            btn: btn,
            callBack: function (index, layero) {
                layer.close(index);
            }
        };
        $.modal.openOptions(options);
    }
    function openNotices() {
        $.modal.openTab('通知公告', ctx + "system/notice");
    }
</script>
</body>
</html>
